package com.zenith.yasoo.party;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import com.zenith.yasoo.setup.ContactMechPurposeType;
import com.zui.base.BaseEntity;


@Entity
@Table(name="party_contact_mech_purpose",
		uniqueConstraints={@UniqueConstraint(name="uc_party_contact_mech_pur",
				columnNames={"partyContactMechId", "contactMechPurposeTypeCode"})})
/**
 * PartyContactMech与ContactMechTypePurpose之间的中间表，有两个额外字段fromDate和thruDate.
 * PartyContactMech本身也是一个中间表（Party与ContactMech）
 * PartyContactMech可访问Purpose,反之则不行。
 * 
 * 
 * @author Sam
 */
public class PartyContactMechPurpose extends BaseEntity{
	private static final long serialVersionUID = 1L;
	
	private PartyContactMech partyContactMech;
	private ContactMechPurposeType contactMechPurposeType;
	private Date fromDate;
	private Date thruDate;

	
	/*------------------------------
	 * getters and annotations
	 --------------------------------*/
	@ManyToOne @JoinColumn(name="partyContactMechId")
	public PartyContactMech getPartyContactMech() {return partyContactMech;}
	
	@ManyToOne @JoinColumn(name="contactMechPurposeTypeCode")
	public ContactMechPurposeType getContactMechPurposeType() {return contactMechPurposeType;}
	
	@Temporal(value=TemporalType.DATE)
	public Date getFromDate() {return fromDate;}
	@Temporal(value=TemporalType.DATE)
	public Date getThruDate() {return thruDate;}
	
	public void setPartyContactMech(PartyContactMech partyContactMech) {
		this.partyContactMech = partyContactMech;
	}
	public void setContactMechPurposeType(
			ContactMechPurposeType contactMechPurposeType) {
		this.contactMechPurposeType = contactMechPurposeType;
	}
	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}
	public void setThruDate(Date thruDate) {
		this.thruDate = thruDate;
	}
	
}
